<template>
  <div>
    <a-table :columns="columnsList" :data-source="list" :pagination="false" :scroll="{ y: 400 }">
    </a-table>
  </div>
</template>

<script>
import { getAction } from '@/api/manage'
export default {
  name: 'RelativeProduct',
  props: {
    /** 模块ID */
    id: [String, Number],
  },
  data() {
    return {
      columnsList: [
        {
          title: '产品分类',
          dataIndex: 'categoryName_dictText',
          key: 'categoryName',
        },
        {
          title: '产品名称',
          dataIndex: 'name',
          key: 'name',
          width: 100,
        },
        {
          title: '产品单位',
          dataIndex: 'unit_dictText',
          key: 'unit',
        },
        {
          title: '标准价格',
          key: 'price',
          dataIndex: 'price',
        },
        {
          title: '售价',
          key: 'salesPrice',
          dataIndex: 'salesPrice',
        },
        {
          title: '数量',
          key: 'num',
          dataIndex: 'num',
        },
        {
          title: '折扣',
          key: 'discount',
          dataIndex: 'discount',
        },
        {
          title: '小记',
          key: 'subtotal',
          dataIndex: 'subtotal',
        },
      ],
      list: [],
      url: {
        pagingContractItemList: '/online/api/pagingContractItemList',
      },
    }
  },
  components: {
  },
  watch: {
      id(val){
        this.getDetail()
      }
    },
  created() {
    this.getDetail()
  },
  methods: {
    getDetail() {
      const params = {}
      params[`contractId`] = this.id
      getAction(this.url.pagingContractItemList, params)
        .then((res) => {
          if (res.success) {
            this.list = res.result
          }
        })
        .catch(() => {})
    },
  },
}
</script>

<style lang="less" scoped>
/deep/ .ant-btn {
  color: #fff;
  background-color: #168a40;
  border-color: #168a40;
}
/deep/ .ant-table {
  border: 1px solid rgb(230, 230, 230);
}
</style>